package cn.usian.controller;

import cn.usian.jyzx.model.entity.h5.CartInfo;
import cn.usian.jyzx.model.vo.common.Result;
import cn.usian.jyzx.model.vo.common.ResultCodeEnum;
import cn.usian.service.CartService;
import feign.RequestTemplate;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("/api/order/cart")
public class CartController {
    @Autowired
    CartService cartService;

    @RequestMapping("auth/addToCart/{stuId}/{stuNum}")
    public Result addCart(@PathVariable Long stuId, @PathVariable Integer stuNum){

        cartService.toCart(stuId,stuNum);
        return Result.build(null, ResultCodeEnum.SUCCESS);
    }

    @GetMapping("auth/cartList")
    public Result<List<CartInfo>> cartList(){
        return cartService.cartList();
    }

    @DeleteMapping("/auth/deleteCart/{id}")
    public Result deleteCart(@PathVariable Integer id){
        return cartService.deleteCart(id);
    }

    @GetMapping("auth/checkCart/{id}/{isChecked}")
    public Result checkCart(@PathVariable Integer id,@PathVariable Integer isChecked){
        return cartService.checkCart(id,isChecked);
    }

    @GetMapping("auth/allCheckCart/{isChecked}")
    public Result allCheckCart(@PathVariable Integer isChecked){
        return cartService.allCheckCart(isChecked);
    }

    @GetMapping("auth/clearCart")
    public Result clearCart(){
        return cartService.clearCart();
    }


}
